﻿/*
 * Created by SharpDevelop.
 * User: Alice
 * Date: 09.03.2012
 * Time: 17:05
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.Collections;

namespace monoServer
{
	/// <summary>
	/// Description of Session.
	/// </summary>
	public class Session
	{
		private User _user;
		public User User
		{
			get
			{
				return this._user;
			}
			set
			{
				this._user = value;
				this.isLoggedIn = this._user.IsLoggedIn;
			}
		}
		public string key;
		public DateTime lastPing;
		public CommunicatorParallel com;
		public bool clientThreadStarted;
		public bool isLoggedIn;

		public Session(String keyValue)
		{
			this.isLoggedIn = false;
			this.clientThreadStarted = true;
			this.key = keyValue;
			this.User = new User();
		}
		
		public void logout()
		{
			this.com.sendLogout();
			this.com.closeConnection();
			this.clientThreadStarted = false;
		}
		
		public void sendUserData()
		{
			this.com.sendUserData(this.User);
		}
		
		/*
		public void sendChat(SortedList messages)
		{
			for(int i=0;i<=messages.Count-1;i++)
			{
				Hashtable h = (Hashtable)messages.GetByIndex(i);
				String message = (String)h["message"];
				int timestamp = (int)h["timestamp"];
				this.com.sendChatMessage(message,this,timestamp);
			}
		}
		*/
	}
}
